<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>

<%@ page import="static org.six11.olive3.server.WebActionServlet.*"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Picturephone: Browse</title>
<link rel="stylesheet" href="css/style.css" TYPE="text/css">

</head>
<body>

<div class="head">Picturephone Data</div>

<jsp:include page="nav.jsp" />

<div style="height: 60px"></div>

<c:forEach items="${drillData}" var="d" varStatus="s">

	<!-- On all iteractions except the first, draw an arrow indicating a parent/child relation -->
	<c:if test="${s.first=='false'}">
		<div class="downArrow"><img src="static_img/down_arrow.png" /></div>
	</c:if>

	<!-- See if this is a sketch or a description. -->
	<c:choose>
		<c:when test="${d.type=='sketch'}">
		<!-- This 'when' clause is for sketches -->
			<table>
				<tr><td>
				<a class="toggleborder"
					href="<%=WEB_ACTION_SHORT%>?<%=PARAM_ACTION%>=<%=ACTION_BROWSE%>&AMP;<%=PARAM_SKETCH_ID%>=${d.id}">
					<img border="0" src="${d.smallPngUrl}" /> 
				</a>
				</td>
				<td class="smallInfo">
				<!-- For sketches we may have no ratings. Say 'unrated' if that is the case. -->
					<c:choose>
						<c:when test="${d.numRatings=='0'}">
							Unrated!
						</c:when>
						<c:otherwise>
							${d.aveRating} / 5 (rated ${d.numRatings} times)
						</c:otherwise>
					</c:choose> 
					(<a href="${d.pdfUrl}">PDF</a> | <a href="${d.pngUrl}">PNG</a> | 
					<a href="${d.penUrl}">Raw Pen Data</a>)
				</td>
				</tr></table>		
		</c:when>
		<c:otherwise>
			<!--  This 'when' clause is for descriptions -->
			<div class="quoteBlock"><a
				href="<%=WEB_ACTION_SHORT%>?<%=PARAM_ACTION%>=<%=ACTION_BROWSE%>&AMP;<%=PARAM_DESC_ID%>=${d.id}">${d.text}</a>
			</div>
		</c:otherwise>
	</c:choose>

</c:forEach>

<c:choose>
	<c:when test="${fn:length(leaves) > 0}">
		<p>Here's all the stuff based on the last item (click to drill
		down into them):</p>
		<br />
		<br />
		<br />
		<c:forEach items="${leaves}" var="leaf">
			<c:choose>
				<c:when test="${leaf.type=='sketch'}">
					<a class="toggleborder"
						href="<%=WEB_ACTION_SHORT%>?<%=PARAM_ACTION%>=<%=ACTION_BROWSE%>&AMP;<%=PARAM_SKETCH_ID%>=${leaf.id}">
					<img border="0" src="${leaf.smallPngUrl}" /> </a>
				</c:when>
				<c:otherwise>
					<div class="description"><a
						href="<%=WEB_ACTION_SHORT%>?<%=PARAM_ACTION%>=<%=ACTION_BROWSE%>&AMP;<%=PARAM_DESC_ID%>=${leaf.id}">${leaf.text}</a></div>
					<br />
				</c:otherwise>
			</c:choose>
		</c:forEach>
	</c:when>
	<c:otherwise>
		It seems there aren't any sketches or descriptions based on that last thing yet.
	</c:otherwise>
</c:choose>

</body>
</html>